package com.jk.service.impl;

import com.jk.mapper.AuthOrgInfoMapper;
import com.jk.mapper.AuthRepInfoMapper;
import com.jk.service.AuthRepInfoService;
import com.jk.vo.AuthRepInfo;
import com.jk.vo.WorkOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;

/**
 * Created by ${user} on ${data}.
 */
@Service("authRepInfoService")
public class AuthRepInfoServiceImpl implements AuthRepInfoService{
    @Autowired
    private AuthRepInfoMapper authRepInfoMapper;
    public List<Map> SelectAuthRepInfo(AuthRepInfo authRepInfo) {
        return authRepInfoMapper.SelectAuthRepInfo(authRepInfo);
    }

    public int UpdateAuthRepInfo(AuthRepInfo authRepInfo, WorkOrder workOrder) {
       int UpdateAuthRepCount =  authRepInfoMapper.UpdateAuthRepInfo(authRepInfo);
       if(UpdateAuthRepCount!=0){
           workOrder.setWorkoderId(UUID.randomUUID().toString().replaceAll("-", ""));
           workOrder.setWorkoderNo(UUID.randomUUID().toString().replaceAll("-", ""));
           workOrder.setWorkoderDic(1);
           workOrder.setWorkoderTime(new Date());
           authRepInfoMapper.InsertAuthRepInfo(workOrder);
           return 1;//新增修改成功
       }else{
           return 0;//新增修改失败
       }
    }
}
